package hibernate;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import dominio.bean.*;

public class HibernateUtilities {

	private static final SessionFactory sessionFactory;
	
	static 
	{
		try {
			AnnotationConfiguration config = new AnnotationConfiguration();
			config.addAnnotatedClass(Tarifa.class);
			config.addAnnotatedClass(CodigoPostal.class);
			config.addAnnotatedClass(DetalleLiquidacion.class);
			config.addAnnotatedClass(EmpresaTransporte.class);
			config.addAnnotatedClass(FormularioCompraProductos.class);
			config.addAnnotatedClass(Liquidacion.class);
			config.addAnnotatedClass(Peso.class);
			config.addAnnotatedClass(Producto.class);
			config.addAnnotatedClass(SubClase.class);
			
			sessionFactory = config.buildSessionFactory();
		}catch (Throwable ex)
		{
			System.err.println("fallo de inicio de sesion" + ex);
			throw new ExceptionInInitializerError(ex);
		}
	}
	public static SessionFactory getSession(){
		return sessionFactory;
	}
}
